Python 3
import osimport pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as plt%matplotlib inlineos.getcwd()'C:\\Users\\svlsrao\\Documents\\First-Hackathon'
xxxxxxxxxxpath='C:\\Users\\svlsrao\\Documents\\First-Hackathon/file/Train.csv'data=pd.read_csv(path)data.shape(34226, 16)
# To see whether the id numbers or unique or not -we use the command data['id'].nunique(dropna=True)=> drop null values-we use the command data['id'].nunique(dropna=True)=> drop null valuesxxxxxxxxxxdata['id'].nunique(dropna=True)34226
# select only the lat and log values of neighbourhood_group (Manhattan)xxxxxxxxxxdpr=data[data['room_type']=='Private room']xxxxxxxxxxdpr['room_type'].unique()array(['Private room'], dtype=object)
xxxxxxxxxxdpr_mn=dpr[dpr['neighbourhood_group']=='Manhattan']# The above commands can be done using the following single commandxxxxxxxxxxdpr_mn1=data[(data['room_type']=='Private room')&(data['neighbourhood_group']=='Manhattan')]xxxxxxxxxxdpr_mn1.to_csv('Manhattan.csv')xxxxxxxxxxdpr_mn1.head(20)| id | name | host_id | host_name | neighbourhood_group | neighbourhood | latitude | longitude | room_type | price | minimum_nights | number_of_reviews | last_review | reviews_per_month | calculated_host_listings_count | availability_365 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 5728806 | Large private room in Nolita | 4271676 | Nat | Manhattan | Nolita | 40.72217 | -73.99481 | Private room | 120 | 7 | 3 | 2015-09-01 | 0.06 | 3 | 0 |
| 14 | 5040218 | LUX Blg-Prime Area! Lg PRIVATE RM & BATH w/VIEWS! | 26019828 | Sonia | Manhattan | Hell's Kitchen | 40.76159 | -73.99824 | Private room | 69 | 2 | 22 | 2019-03-20 | 0.64 | 2 | 7 |
| 23 | 20587133 | Spacious, bright room in art-filled apartment! | 116758734 | Amos | Manhattan | Inwood | 40.87085 | -73.91830 | Private room | 59 | 4 | 19 | 2018-10-06 | 0.84 | 1 | 0 |
| 31 | 33682823 | New York City Luxury Bedroom!! | 224317184 | Luke | Manhattan | Harlem | 40.81652 | -73.94914 | Private room | 215 | 5 | 7 | 2019-06-21 | 2.73 | 8 | 335 |
| 60 | 4926610 | Panoramic City Views in Lux bldg | 7537442 | Loydeen | Manhattan | East Harlem | 40.80315 | -73.94017 | Private room | 50 | 7 | 25 | 2019-06-28 | 0.50 | 1 | 151 |
| 61 | 34483432 | Manhattan Accommodation Across Central Park | 260425153 | Park Lane | Manhattan | Midtown | 40.76427 | -73.97618 | Private room | 375 | 1 | 1 | 2019-06-30 | 1.00 | 14 | 349 |
| 65 | 17702242 | Stylish Private BR in the Upper East Side | 10661558 | Gio | Manhattan | Upper East Side | 40.77349 | -73.94994 | Private room | 129 | 1 | 117 | 2019-07-04 | 4.20 | 4 | 155 |
| 66 | 30269789 | private room in apt near Fort Tryon Park. | 87897420 | Anne | Manhattan | Inwood | 40.86171 | -73.92945 | Private room | 65 | 4 | 1 | 2019-01-01 | 0.16 | 1 | 13 |
| 68 | 20147537 | Paradise Room (Private Room) | 142812843 | Eugene | Manhattan | East Harlem | 40.79104 | -73.93805 | Private room | 75 | 1 | 12 | 2017-11-05 | 0.51 | 2 | 0 |
| 71 | 10390256 | East Village Apartment | 3078092 | Amanda | Manhattan | East Village | 40.73144 | -73.98355 | Private room | 75 | 1 | 0 | NaN | NaN | 1 | 0 |
| 77 | 36183003 | Private bedroom withWiFi minutes from Central ... | 82406306 | Marc | Manhattan | East Harlem | 40.80128 | -73.93991 | Private room | 78 | 1 | 0 | NaN | NaN | 2 | 13 |
| 81 | 10099517 | Master room in a luxury apartment | 16869971 | Han | Manhattan | Roosevelt Island | 40.76947 | -73.94303 | Private room | 80 | 1 | 1 | 2016-01-05 | 0.02 | 2 | 0 |
| 82 | 18043457 | Spacious Private Room in Nolita | 15651644 | Alan | Manhattan | Chinatown | 40.71866 | -73.99633 | Private room | 120 | 3 | 1 | 2017-05-21 | 0.04 | 1 | 0 |
| 88 | 25482581 | Modern BR with Private Bathroom Near Central Park | 146905275 | Roberto | Manhattan | Upper West Side | 40.77471 | -73.98955 | Private room | 140 | 1 | 50 | 2019-07-02 | 3.71 | 1 | 69 |
| 93 | 18615898 | Welcoming home in the ❤️ of NYC! | 23867523 | K | Manhattan | Theater District | 40.76207 | -73.98580 | Private room | 120 | 1 | 8 | 2019-05-31 | 2.09 | 1 | 5 |
| 99 | 4667146 | Best value double room in New York B4 | 20559017 | Yohan | Manhattan | East Harlem | 40.78512 | -73.94409 | Private room | 50 | 30 | 5 | 2018-12-30 | 0.11 | 9 | 330 |
| 106 | 31704075 | Cozy Manhattan Room | 153793156 | Erika | Manhattan | Morningside Heights | 40.81633 | -73.96069 | Private room | 50 | 2 | 15 | 2019-06-20 | 3.60 | 1 | 2 |
| 118 | 11326009 | Cozy SunLit Room Next To TimeSquare | 13125944 | Calvin | Manhattan | Hell's Kitchen | 40.76510 | -73.98854 | Private room | 79 | 1 | 2 | 2016-05-21 | 0.05 | 2 | 0 |
| 119 | 21883986 | Cozy Room with queen size bed for 2 | 158710682 | Cedar | Manhattan | Midtown | 40.75298 | -73.96912 | Private room | 90 | 1 | 0 | NaN | NaN | 3 | 221 |
| 123 | 23324479 | HARLEM HOME AWAY FROM HOME , SHORT - EXTENDED ... | 120167980 | Judith | Manhattan | Harlem | 40.80497 | -73.94952 | Private room | 125 | 1 | 7 | 2019-05-12 | 0.43 | 1 | 297 |
xxxxxxxxxximport mathlat1=math.radians(40.72217)lon1=math.radians(73.99481)lat2=math.radians(40.7598)lon2=math.radians(73.9851)xxxxxxxxxxprint(lat1)0.7107359450568592
xxxxxxxxxxR=6373.0dlon = lon2 - lon1dlat = lat2 - lat1a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2)**2c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))distance = R * cprint(a,c,distance)1.1195768514883917e-07 0.0006692015819676874 4.264821681880072
xxxxxxxxxxfrom pandas_profiling import ProfileReportprofile = ProfileReport(data, title="Pandas Profiling Report",explorative=True)xxxxxxxxxxprofileInit signature: ProfileReport( df=None, minimal=False, explorative=False, sensitive=False, dark_mode=False, orange_mode=False, sample=None, config_file: Union[pathlib.Path, str] = None, lazy: bool = True, **kwargs, ) Docstring: Generate a profile report from a Dataset stored as a pandas `DataFrame`. Used has is it will output its content as an HTML report in a Jupyter notebook. Init docstring: Generate a ProfileReport based on a pandas DataFrame Args: df: the pandas DataFrame minimal: minimal mode is a default configuration with minimal computation config_file: a config file (.yml), mutually exclusive with `minimal` lazy: compute when needed **kwargs: other arguments, for valid arguments, check the default configuration file. File: c:\users\svlsrao\anaconda3\lib\site-packages\pandas_profiling\profile_report.py Type: type Subclasses: